local skel = fk.CreateSkill{
  name = "tea__wangjian",
}
Fk:loadTranslationTable{
  ["tea__wangjian"] = "妄谮",
  [":tea__wangjian"] = "出牌阶段结束时，你可以与一名其他角色各自将手牌数调整至体力上限（至多摸5张牌）。"..
  "若如此做，你与其同时展示手牌，然后♥牌较少的角色对另一名角色造成1点伤害。",
  ["#tea__wangjian-choose"] = "妄谮：你可以选择一名其他角色",
}
---@type TrigSkelSpec<PhaseFunc>
local wangjian = {
  anim_type = "offensive",
  can_trigger = function (self, event, target, player, data)
    return player:hasSkill(skel.name) and player == target and player.phase == Player.Play
  end,
  on_cost = function (self, event, target, player, data)
    local room = player.room
    local tos = room:askToChoosePlayers(player, {
      min_num = 1,
      max_num = 1,
      skill_name = skel.name,
      targets = room:getOtherPlayers(player),
      prompt = "#tea__wangjian-choose"
    })
    if #tos == 1 then
      event:setCostData(self, { to = tos[1] })
      return true
    end
  end,
  on_use = function (self, event, target, player, data)
    local room = player.room
    local to = event:getCostData(self).to
    for _, p in ipairs({ player, to }) do
      if not p.dead then
        if #p:getCardIds("h") > p.maxHp then
          local num = #p:getCardIds("h") - p.maxHp
          room:askToDiscard(p, {
            min_num = num,
            max_num = num,
            skill_name = skel.name,
            pattern = ".",
            include_equip = false,
          })
        else
          local num = math.min(p.maxHp - #p:getCardIds("h"), 5)
          if num > 0 then
            p:drawCards(num, skel.name)
          end
        end
      end
    end
    player:showCards(player:getCardIds("h"))
    if not to.dead then
      to:showCards(to:getCardIds("h"))
      if not player.dead and not to.dead then
        room:delay(1000)
        local playerNum = #table.filter(player:getCardIds("h"), function(id)
          return Fk:getCardById(id).suit == Card.Heart
        end)
        local toNum = #table.filter(to:getCardIds("h"), function(id)
          return Fk:getCardById(id).suit == Card.Heart
        end)
        local from, too
        if playerNum < toNum then
          from = player
          too = to
        elseif playerNum > toNum then
          from = to
          too = player
        end
        if from and too then
          room:doIndicate(from, { too })
          room:damage{
            from = from,
            to = too,
            damage = 1,
            skillName = skel.name
          }
        end
      end
    end
  end
}
skel:addEffect(fk.EventPhaseEnd, wangjian)
return skel